package com.itheima.health.controller;


import com.itheima.health.UserService;
import com.itheima.health.common.MessageConst;
import com.itheima.health.entity.Result;
import jdk.nashorn.internal.ir.annotations.Reference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("web/user")
public class UserController {

    //依赖注入service对象
    @Reference
    private UserService userService;

    @RequestMapping("login")
    public Result login(String username, String password) {
        System.out.println("oms backend====u:" + username + " ,p:" + password);

        //调用services的  用户登录方法
        if (userService.login(username, password)) {
            //返回正确
            System.out.println("login success!!!");
            return new Result(true,MessageConst.ACTION_SUCCESS);
        } else {
            //返回失败
            System.out.println("login fail");
            return new Result(false,MessageConst.ACTION_FAIL );
        }
    }
}